<template>
	<div>
		<Chart :cdata="cdata" />
	</div>
</template>

<script>
	import Chart from './chart.vue'
	export default {
		data() {
			return {
				cdata: {
					time: [],
					lineoData: [],
					linetData: [],
				}
			};
		},
		components: {
			Chart,
		},
		mounted() {
			this.getGY()
		},
		methods: {
			getGY() {
				this.$http.get("/view/gy_statistics/list").then((res) => {
					console.log("=======>gy", res.data.rows)
					let gys = res.data.rows
					let datax = []
					let datay = []
					let dataz = []
					// 循环遍历数组，取出数据，转成和data一样的格式
					for (var i = 0; i < gys.length; i++) {
						datax.push(gys[i].weatherTime)
						datay.push(gys[i].temperature)
						dataz.push(gys[i].windScale)
					}
					this.cdata.time = datax
					this.cdata.lineoData = datay
					this.cdata.linetData = dataz
					// this.cdata.serData = data
				}).catch((err) => {
					console.log(err)
					alert('请求失败！请检查后端接口！！！！')
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
</style>
